/*
 * client_log.h
 *
 *  Created on: Jan 11, 2014
 *      Author: killerg
 */

#ifndef CLIENT_LOG_H_
#define CLIENT_LOG_H_

enum EConsumeType {         //                  misc
    ECT_BuyItem = 1,        // 买物品            原型id
    ECT_ArenaCombatNum = 2, // 购买竞技场战斗次数
    ECT_OccupationNum = 3,  // 占坑次数
    ECT_RandEgg = 4,        // 摇蛋消耗           几号摇蛋机
    ECT_ArenaCrit = 5,      // 竞技场突袭
    ECT_LuckyStarNum = 6,   // 幸运星摇奖
    ECT_VentureRent = 7,    // 探险租赁道具
    ECT_ComposeStone = 8,   // 合成强化石
    ECT_SpriteStarWalk = 9,// 妖精探索星
    ECT_EquipStar = 10,     // 装备洗星
};

enum EEventType {              //           misc
    EET_GainGiftBag = 1,       // 领取礼包   rewardid
    EET_HatchEgg = 2,          // 孵化蛋
    EET_Explore = 3,           // 探险次数
};

struct client_stat_t {
    int64_t playerid;
    std::string name;
    std::string account;
    std::string machine_code;
    int32_t idmask;

    // 时间记录 -------------------------------------------------------------------
    time_t logon;
    time_t logoff;
    time_t conn_start;
    time_t conn_end;
    time_t create_start;    // 创建玩家
    time_t create_end;
    time_t load_start;      // 加载时间
    time_t load_end;

    // 消耗记录 -----------------------------------------------------------------------
    // 玩家买物品
    struct consume_t {
        EConsumeType ect;
        int32_t misc;
        int32_t consume_gamemoney;
        int32_t consume_money;
        consume_t() {
            memset(this, 0, sizeof(*this));
        }
    };

    std::vector<consume_t> consume_log;

    // 事件记录 -----------------------------------------------------------------------
    struct event_t {
        EEventType eet;
        int32_t misc;
        event_t() {
            memset(this, 0, sizeof(*this));
        }
    };

    std::vector<event_t> event_log;

    void reset();
    void post_save();
    void add_consume_byval(EConsumeType ect, int32_t misc = -1, int32_t money = 0, int32_t gamemoney = 0);
    void add_consume_byid(EConsumeType ect, int32_t misc = -1, int32_t consumeid = -1);
    void add_event(EEventType eet, int32_t misc = -1);
    void add_bill(time_t time, double fee);
};



#endif /* CLIENT_LOG_H_ */
